import { createStore, combineReducers } from 'redux'

//状态有多个属性要...
const loginReducer = (state = { isLogin: false }, action) => {

    switch (action.type) {
        case 'login':
            return { ...state, isLogin: true }

        default:
            return state;

    }
}

const homeReducer = (state = { list: [1, 2] }, action) => {

    switch (action.type) {
        case 'add_item':
            return { ...state, list: [action.payload, ...state.list] }

        default:
            return state;
    }
}

const rootRedeucer = combineReducers({
    loginData: loginReducer,
    homeData: homeReducer
})
const store = createStore(rootRedeucer);
export default store;